package com.ptp.push; 
/** 
 * @author liningning 
 * @date 2018年12月4日 下午2:50:53 
*/

import java.util.Map;

import io.netty.channel.Channel;
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;

public interface IPush {

	default void push(String userId,String receiveId, Map<String, Channel> channels,String message) {
		Channel channel = channels.get(receiveId);
		//对方不在线,进行数据持久化,推送一条消息到服务端 TODO
		if(channel == null){
			channel = channels.get(userId);
			channel.writeAndFlush(new TextWebSocketFrame("对方不在线,消息有延迟"));
		}else{
			channel.writeAndFlush(new TextWebSocketFrame(message));
			channel = channels.get(userId);
			channel.writeAndFlush(new TextWebSocketFrame("消息发送成功"));
		}
	}
}
